import {createBrowserRouter, Navigate} from "react-router-dom";
import menuData from "./menu";
import Admin from "@/pages/Admin";
import H5 from "@/pages/H5";
import Web from "@/pages/Web";
import Home from "@/pages/home";
import {routerPath} from "./path";
const {admin, h5, web, home} = routerPath;

const routers = createBrowserRouter([
    {
        path: home,
        element: <Home />,
        loader: () => menuData,
        children: [
            {
                index: true, // 确定该路由是否为索引路由。索引路由在其父级 URL 处呈现到其父级 Outlet（类似于默认子路由）。
                element: <Navigate to={admin} replace />,
            },
            {
                path: admin,
                element: <Admin />,
            },
            {
                path: h5,
                element: <H5 />,
            },
            {
                path: web,
                element: <Web />,
            },
        ],
    },
]);
export default routers;
